<?php
namespace app\api\job;

use think\Queue;

class SendMessage
{
    public static function sendMessage(array $data){//data 是你要处理的数据

        $jobHandlerClassName = 'app\api\job\Message';
        //当前任务归属的队列名称，如果为新队列，会自动创建
        $jobQueueName = $data['job_queue_name'];
        //立即执行
        // $isPushed = Queue::push( $jobHandlerClassName , $data , $jobQueueName );
        //延时   (s)秒  //wheat_duration创建房间时的说话时长
        $isPushed = Queue::later($data['wheat_duration'],$jobHandlerClassName,$data,$jobQueueName);

//        $isPushed = Queue::later(60,$jobHandlerClassName,$data,$jobQueueName);

        if ($isPushed !== false) {
            return false;
        }
        return true;
    }
}
